
import { ElMessage } from "element-plus";
import screenfull from "screenfull";
export const useIconStore = defineStore("handleIcon", () => {
    const positionWisth = ref("0px"); // 调整right or left来收起或展示左右两侧的信息框
    const showRightOrLeft = ref(true); // 用于调整right or left来收起或展示左右两侧的信息框flag
    // 点击图标收起或展示
    const handleShowOrHid = () => {
        if (showRightOrLeft.value == true) {
            positionWisth.value = "-380px";
        } else {
            positionWisth.value = "0px";
        }
        showRightOrLeft.value = !showRightOrLeft.value;
    };
    const showLayerTree = ref(true);
    // 点击展开收起图层树
    const showOrHiddenLayerTree = () => {
        showLayerTree.value = !showLayerTree.value;
    };
    // 浏览器全屏
    const isFullscreen = ref(false);
    const clickFullScreenIcon = () => {
        if (!screenfull.isEnabled) {
            ElMessage({
                message: "你的浏览器不支持全屏",
                type: "warning",
            });
            return false;
        }
        screenfull.toggle();
    };
    const changeScreen = () => {
        isFullscreen.value = screenfull.isFullscreen;
    };
    const initScreenfull = () => {
        if (screenfull.isEnabled) {
            screenfull.on("change", changeScreen);
        }
    };
    const destroyScreenFull = () => {
        if (screenfull.isEnabled) {
            screenfull.off("change", changeScreen);
        }
    };
    const zoomIn = (map) => {
        map.zoomIn();
    };
    const zoomOut = (map) => {
        map.zoomOut();
    };
    return {
        positionWisth,
        showRightOrLeft,
        handleShowOrHid,
        showLayerTree,
        showOrHiddenLayerTree,
        clickFullScreenIcon,
        isFullscreen,
        destroyScreenFull,
        initScreenfull,
        zoomIn,
        zoomOut,
    };
});
